<template>
  <my-scroll class="my-scroll"
             :dataResource='albums'
             ref="scroll"
             :pullDown="true"
             @pulldown="pulldown">
    <div class="recommend">
      <slide :resources="slideData"
             v-if="slideData.length"></slide>
      <List :resource="albums"
            @onClickItem="goSingerPage"
            ref="list"></List>
    </div>
  </my-scroll>

</template>
<script>
import slide from '@com/base/slide.vue'
import { getRecommend } from '@/api/recommend.js'
import List from '@com/list.vue/list.vue'
import MyScroll from '@com/base/myScroll.vue'
export default {
  data () {
    return {
      slideData: [],
      albums: []
    }
  },
  components: {
    slide,
    List,
    MyScroll
  },
  created () {
    this.getRecommend()
  },
  methods: {
    async getRecommend () {
      const result = await getRecommend()
      this.slideData = result.sliders
      this.albums = result.albums
    },
    goSingerPage () {
      this.$router.push('/singer')
    },
    pulldown () {
      this.slideData = []
      this.albums = []
      this.getRecommend()
    }
  }
}
</script>
<style scoped lang = 'scss'>
.my-scroll {
  width: 100%;
  position: absolute;
  top: 88px;
  bottom: 0px;
  overflow: hidden;
}
</style>
